package algotithm.interview.携程test.test1;

import java.io.*;

/**
 * @author zhouyanxiang
 * @Date 2021-03-2021/3/18-19:04
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String s1 = reader.readLine().replaceAll(" ","");
        String s2 = reader.readLine().replaceAll(" ","");
        int num = calcSimilarity(s1,s2);
        writer.write(num + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }

    static int calcSimilarity(String name1, String name2) {
        int n = name1.length();
        int m = name2.length();
        int[][] dp = new int[n+1][m+1];
        for (int i = n - 1; i >= 0; i--) {
            dp[i][m] = dp[i+1][m] + name1.codePointAt(i);
        }
        for (int j = m - 1; j >= 0; j--) {
            dp[n][j] = dp[n][j+1] + name2.codePointAt(j);
        }
        for (int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if (name1.charAt(i) == name2.charAt(j)) {
                    dp[i][j] = dp[i+1][j+1];
                } else {
                    dp[i][j] = Math.min(dp[i+1][j] + name1.codePointAt(i),dp[i][j+1] + name2.codePointAt(j));
                }
            }
        }
        return dp[0][0];
    }


}
